// var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJ1c2VySWRcIjo3NyxcInVzZXJuYW1lXCI6XCIxNTgxMTU2MTE3M1wiLFwicGFzc3dvcmRcIjpcIjQxRDJGNjk4NzQyMzg0NkI3ODc2RDE4ODUwNTY4OEZFXCIsXCJ0aE9wZW5pZFwiOm51bGwsXCJtb2JpbGVcIjpudWxsLFwic3VuZ29JZFwiOm51bGwsXCJuaWNrbmFtZVwiOm51bGwsXCJoZWFkUG9ydHJhaXRcIjpudWxsLFwiYWRkVGltZVwiOm51bGwsXCJiaXJ0aGRheVwiOm51bGwsXCJzZXhcIjpudWxsLFwiaGVpZ2h0XCI6bnVsbCxcIndlaWdodFwiOm51bGwsXCJzbW9rZVwiOm51bGwsXCJkcmlua1wiOm51bGwsXCJlYXRIb2JieVwiOm51bGwsXCJqb2JUeXBlXCI6bnVsbCxcImxhYmVsXCI6bnVsbH0iLCJleHAiOjE1Mjg4NjkxNTN9.zr6BxTaV93UHfvSx1mYqlFJPNp1qeb5mWJo7TQ8AMjs';
// fnWeb('2018-05-16','77','77',token);
function fnOrgans(addTime, userId, friendId, token) { //初始化
	organsDate(addTime, userId, friendId, token);
}
//接口
function organsDate(addTime, userId, friendId, token) { //脏腑
	var url = "http://api.sungohealth.com/viscera/data";
	var data = {
		addTime: addTime,
		userId: userId,
		friendId: friendId,
		token: token
	};
	$.ajax({
		type: "POST",
		url: url,
		data: data,
		dataType: "json",
		success: function(data, status, xhr) {
			console.log(data);
			if(data.status == '0' || data.msg == '成功') {
				$('.unEmpty').removeClass('dn');
				$('.empty').addClass('dn');
				fn_option_zf(addTime, data.data); //数据渲染
			} else {
				$('.unEmpty').addClass('dn');
				$('.empty').removeClass('dn');
			}
		},
		error: function(result) {
			console.log(result);
		}
	});
}

//接口测试数据
//var dataTemp = {
//	"status": 0,
//	"data": {
//		"visceraId": 390,
//		"userId": 77,
//		"zhCnSpleen": "亢奋",
//		"zhCnKidney": "亢奋",
//		"zhCnLungs": "平和",
//		"zhCnLiver": "受限",
//		"zhCnHeart": "受限",
//		"intSpleen": "138",
//		"intKidney": "139",
//		"intLungs": "111",
//		"intLiver": "28",
//		"intHeart": "47",
//		"dataDate": "2018-05-16",
//		"visceraFunc": "47",
//		"visceraBalance": "46",
//		"visceraCode": "肾脏，脾脏，肺脏气血运行活跃、功能亢奋，心脏，肝脏气血运行不畅、功能降低。",
//		"heartRate": "1",
//		"restingRate": "91",
//		"cardiacFunc": "中年",
//		"systolicPressure": "120",
//		"diastolicPressure": "60",
//		"addTime": "2018-05-16 16:42:14",
//		"averageVisceras": [{
//				"averageVisceraId": 131,
//				"userId": 77,
//				"dataDate": "2018-05-16",
//				"addTime": 1526449274000,
//				"visceraCode": "130010001,130001001,130000101,131111102,131000001,130100001,132222202",
//				"updateTime": "16:42:14",
//				"averageBalance": "46",
//				"averageFunc": "47",
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "亢奋",
//				"zhCnLungs": "亢奋",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "164",
//				"intKidney": "148",
//				"intLungs": "139",
//				"intLiver": "46",
//				"intHeart": "36",
//				"systolicPressure": "130",
//				"diastolicPressure": "70"
//			},
//			{
//				"averageVisceraId": 107,
//				"userId": 77,
//				"dataDate": "2018-05-15",
//				"addTime": 1526351088000,
//				"visceraCode": "130010001,130000101,139999902,130001001,131111102,131000001,130100001,132222202",
//				"updateTime": "16:00:32",
//				"averageBalance": "73",
//				"averageFunc": "77",
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "受限",
//				"zhCnLungs": "受限",
//				"zhCnLiver": "平和",
//				"zhCnHeart": "受限",
//				"intSpleen": "126",
//				"intKidney": "102",
//				"intLungs": "110",
//				"intLiver": "76",
//				"intHeart": "47",
//				"systolicPressure": "125",
//				"diastolicPressure": "75"
//			},
//			{
//				"averageVisceraId": 98,
//				"userId": 77,
//				"dataDate": "2018-05-14",
//				"addTime": 1526282433000,
//				"visceraCode": "130010001,130001001,139999902,131000001,130100001,130000101,132222202",
//				"updateTime": "16:00:55",
//				"averageBalance": "81",
//				"averageFunc": "80",
//				"zhCnSpleen": "平和",
//				"zhCnKidney": "受限",
//				"zhCnLungs": "平和",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "99",
//				"intKidney": "97",
//				"intLungs": "79",
//				"intLiver": "78",
//				"intHeart": "46",
//				"systolicPressure": "113",
//				"diastolicPressure": "59"
//			},
//			{
//				"averageVisceraId": 82,
//				"userId": 77,
//				"dataDate": "2018-05-12",
//				"addTime": 1526137806000,
//				"visceraCode": "130010001,130001001,130000101,131111102,131000001,130100001,132222202",
//				"updateTime": "23:26:39",
//				"averageBalance": "54",
//				"averageFunc": "56",
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "亢奋",
//				"zhCnLungs": "亢奋",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "137",
//				"intKidney": "129",
//				"intLungs": "142",
//				"intLiver": "48",
//				"intHeart": "36",
//				"systolicPressure": null,
//				"diastolicPressure": null
//			},
//			{
//				"averageVisceraId": 72,
//				"userId": 77,
//				"dataDate": "2018-05-11",
//				"addTime": 1526031688000,
//				"visceraCode": "130001001,139999902,131000001,130100001,130010001,130000101,132222202",
//				"updateTime": "17:50:16",
//				"averageBalance": "84",
//				"averageFunc": "63",
//				"zhCnSpleen": "受限",
//				"zhCnKidney": "受限",
//				"zhCnLungs": "受限",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "81",
//				"intKidney": "65",
//				"intLungs": "75",
//				"intLiver": "61",
//				"intHeart": "33",
//				"systolicPressure": "110",
//				"diastolicPressure": "50"
//			},
//			{
//				"averageVisceraId": 59,
//				"userId": 77,
//				"dataDate": "2018-05-10",
//				"addTime": 1525924256000,
//				"visceraCode": "130100001,139999902,130010001,130001001,130000101,131111102,131000001,132222202",
//				"updateTime": "11:50:56",
//				"averageBalance": "36",
//				"averageFunc": "35",
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "亢奋",
//				"zhCnLungs": "亢奋",
//				"zhCnLiver": "平和",
//				"zhCnHeart": "受限",
//				"intSpleen": "190",
//				"intKidney": "157",
//				"intLungs": "190",
//				"intLiver": "84",
//				"intHeart": "27",
//				"systolicPressure": "120",
//				"diastolicPressure": "60"
//			},
//			{
//				"averageVisceraId": 31,
//				"userId": 77,
//				"dataDate": "2018-05-07",
//				"addTime": 1525693088000,
//				"visceraCode": "130100001,130010001,130000101,139999902,130001001,131111102,131000001,132222202",
//				"updateTime": "19:38:08",
//				"averageBalance": "81",
//				"averageFunc": "84",
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "平和",
//				"zhCnLungs": "平和",
//				"zhCnLiver": "平和",
//				"zhCnHeart": "受限",
//				"intSpleen": "126",
//				"intKidney": "107",
//				"intLungs": "106",
//				"intLiver": "85",
//				"intHeart": "70",
//				"systolicPressure": "130",
//				"diastolicPressure": "70"
//			}
//		],
//		"visceraArrayList": [{
//				"visceraId": 390,
//				"userId": 77,
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "亢奋",
//				"zhCnLungs": "平和",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "138",
//				"intKidney": "139",
//				"intLungs": "111",
//				"intLiver": "28",
//				"intHeart": "47",
//				"dataDate": "2018-05-16",
//				"visceraFunc": "58",
//				"visceraBalance": "54",
//				"visceraCode": "肺脏气血运行良好、功能平和，肾脏，脾脏气血运行活跃、功能亢奋，心脏，肝脏气血运行不畅、功能降低。",
//				"heartRate": "1",
//				"restingRate": "91",
//				"cardiacFunc": "中年",
//				"systolicPressure": "150",
//				"diastolicPressure": '80',
//				"addTime": "2018-05-16 16:42:14"
//			},
//			{
//				"visceraId": 351,
//				"userId": 77,
//				"zhCnSpleen": "亢奋",
//				"zhCnKidney": "亢奋",
//				"zhCnLungs": "亢奋",
//				"zhCnLiver": "受限",
//				"zhCnHeart": "受限",
//				"intSpleen": "190",
//				"intKidney": "157",
//				"intLungs": "168",
//				"intLiver": "65",
//				"intHeart": "25",
//				"dataDate": "2018-05-16",
//				"visceraFunc": "35",
//				"visceraBalance": "36",
//				"visceraCode": "肾脏，脾脏，肺脏气血运行活跃、功能亢奋，心脏，肝脏气血运行不畅、功能降低。",
//				"heartRate": "7",
//				"restingRate": "91",
//				"cardiacFunc": "青少年",
//				"systolicPressure": "150",
//				"diastolicPressure": '80',
//				"addTime": "2018-05-16 13:41:14"
//			}
//		]
//	}
//};
//fn_option_zf('2018-05-11', dataTemp.data);

function fn_option_zf(time, data) {
//	$('.unEmpty').removeClass('dn');
//	$('.empty').addClass('dn');

	//页面展示信息
	//评星
	/*
	5星~100分
	4.5星~ >=90分
	4星~ >=80分
	3.5星~ >=70分
	3星~ >=60分
	*/

	/*
   目前得分会有60分以下的。
   5星=100分，4.5星>=90分，
   4星>=80分，3.5星>=70分，
   3星>=60分，2.5星>=50分，
   2星>=40分，1.5星>=30分，
   else1星
    */

	function star_number(star) { //数值分类
		if(!star) {
			return 0;
		} else {
			if(star == 100) {
				return 5;
			} else if(star >= 90) {
				return 4.5;
			} else if(star >= 80) {
				return 4;
			} else if(star >= 70) {
				return 3.5;
			} else if(star >= 60) {
				return 3;
			} else if(star >= 50) {
				return 2.5;
			} else if(star >= 40) {
				return 2;
			} else if(star >= 30) {
				return 1.5;
			} else if(star > 0) {
				return 1;
			} else if(star == 0) {
				return 0;
			}
		}
	}

	star_sun('.organs_star0', star_number(data.visceraFunc)); //脏腑功能
	star_sun('.organs_star1', star_number(data.visceraBalance)); //脏腑平衡

	$(".olState_zf li").html(data.visceraCode); //运动状态提示

	//脏腑平衡状态
	if(data.heartRate) {
		$(".organs0_1").html(data.heartRate);
	} //呼吸率
	if(data.restingRate) {
		$(".organs0_2").html(data.restingRate);
	} //静息心率
	if(data.cardiacFunc) {
		$(".organs0_3").html(data.cardiacFunc);
	} //心脏功能

	/*var colorList = [
	    '#86d9e0',
	    '#75c1c8',
	    '#67b0b7',
	    '#54979e',
	    '#48888f',
	    '#427c83',
	    '#3d737a'
	];*/
	var colorList = [
		'#1baeba',
		'#1cb8c5',
		'#1cc3d1',
		'#1edbea',
		'#1fe6f6',
		'#20edfe',
		'#2decfb',
		'#39ebf9',
		'#45ebf8',
		'#52ecf8',
		'#5eedf8',
		'#6ceef8',
		'#79eff8',
		'#87f0f8',
		'#95f0f7',
		'#a4f1f7',
		'#b3f4f9',
		'#c5f7fb',
		'#d4f7fa',
		'#dff6f8',
		'#ebf7f8',
		'#f5f8f8',
		'#fafcfc',
	];

	//数据处理
	var last16 = dayList(time).last16; //日期
	var dataTemp = dayList(time).ecShow; //echart日期
	var uesTemp = dayList(time).ecUse; //echart日期下标

	//运动-数据
	var organs1_data1 = [],
		organs1_data2 = [],
		organs1_data3 = [],
		organs1_data4 = [],
		organs1_data5 = [],
		organs1_data6 = [],
		organs1_data7 = [],
		organs1_data8 = [];
	var data_arr1 = data.averageVisceras;

	if(data_arr1) { //不为空
		$.each(last16, function(key, val) { //日期数据比对，生成echart需要数据
			$.each(data_arr1, function(k, v) { //昼夜节律趋势分析
				if(val == v.dataDate) {
					organs1_data1[key] = v.intHeart; //心
					organs1_data2[key] = v.intLiver; //肝
					organs1_data3[key] = v.intKidney; //肾
					organs1_data4[key] = v.intSpleen; //脾
					organs1_data5[key] = v.intLungs; //肺
					organs1_data6[key] = v.systolicPressure; //收缩压
					console.info("收缩压:" + v.systolicPressure)
					organs1_data7[key] = v.diastolicPressure; //舒张压
					console.info("舒张压:" + v.diastolicPressure)

					organs1_data8[key] = v.systolicPressure - v.diastolicPressure;
					console.info(v.systolicPressure - v.diastolicPressure)
				}
			});
		});

		if(organs1_data1.length < 16) {
			organs1_data1[15] = '';
		} //数组不足16个时
		if(organs1_data2.length < 16) {
			organs1_data2[15] = '';
		}
		if(organs1_data3.length < 16) {
			organs1_data3[15] = '';
		}
		if(organs1_data4.length < 16) {
			organs1_data4[15] = '';
		}
		if(organs1_data5.length < 16) {
			organs1_data5[15] = '';
		}
		if(organs1_data6.length < 16) {
			organs1_data6[15] = '';
		}
		if(organs1_data7.length < 16) {
			organs1_data7[15] = '';
		}
		if(organs1_data8.length < 16) {
			organs1_data8[15] = '';
		}
	}
	// console.log()

	var organs0_data1 = [];
	var menu = '';
	var menu2 = '';
	var data_arr0 = data.visceraArrayList;

	//	console.log(data_arr0);
	if(data_arr0) { //不为空

		$.each(data_arr0, function(key, val) { //脏腑平衡状态
			var obj = {};
			obj.value = [];
			obj.itemStyle = {};

			/*
			obj.value[0] = Math.round(650-parseInt(val.intHeart));//心
			obj.value[1] = Math.round(1600-(1600/650*parseInt(val.intLiver)));//肝
			obj.value[2] = Math.round(3000-(3000/650*parseInt(val.intKidney)));//肾
			obj.value[3] = Math.round(3800-(3800/650*parseInt(val.intSpleen)));//脾
			obj.value[4] = Math.round(5200-(5200/650*parseInt(val.intLungs)));//肺
			*/
			//max值为均等的时候，不需要对数据做处理
			obj.value[0] = val.intHeart; //心
			obj.value[1] = val.intLiver; //肝
			obj.value[2] = val.intKidney; //肾
			obj.value[3] = val.intSpleen; //脾
			obj.value[4] = val.intLungs; //肺

			obj.itemStyle.color = colorList[key];
			organs0_data1[key] = obj;
			//雷达图，每次的循环
			menu += '<div class="swiper-slide"><h1 class="organs_h1">' + val.visceraTime.split(' ')[1] + '</h1><div class="organs_sub" id="organs_sub' + key + '"></div></div>'

			var sz = '';
			var ss = '';
			var sj = '';
			if(val.systolicPressure) {
				sj = val.visceraTime.split(' ')[1];

			} else {
				sj = '';
			}
			if(val.systolicPressure) {
				ss = val.systolicPressure;
			} else {
				ss = '--';
			}

			if(val.diastolicPressure) {
				sz = val.diastolicPressure;
			} else {
				sz = '--';
			}

			menu2 += '<div class="swiper-slide js-modal-open6" style="width:100%">' +
				'<div><b class="organs0_6">' + sj + '</b></div>' +
				'<ul class="wordages comBox js-modal-open6">' +
				'<li class="comFlex js-modal-open6">' +
				'<h2 >收缩压</h2>' +
				'<h3><b class="organs0_4">' + ss + '</b></h3>' +
				'</li>' +
				//				'<div class="am-modal am-modal-no-btn" tabindex="-1" id="your-modal6"><div class="am-modal-dialog"><div class="am-modal-hd"><span class="sun_title ico_note2">血压标准 </span><a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a></div><div class="am-modal-bd"><div class="xybz">	<div><table><tr><td>血压定义</td><td>范围（mmHg）</td></tr><tr><td>低血压</td><td>收缩压&lt;90mmHg<br />舒张压&lt;60mmHg</td></tr><tr><td>正常血压</td><td>收缩压（90~120）mmHg<br />舒张压（60~80）mmHg</td></tr><tr><td>血压升高</td><td>收缩压（120〜129）mmHg<br />舒张压&lt;80mmHg</td></tr><tr><td>1期高血压</td><td>收缩压（130-139）mmHg<br />舒张压（80-89）mmHg</td></tr><tr><td>2期高血压</td><td>收缩压≧140<br />舒张压90mmHg</td></tr></table></div><p class="shoudi">当测量数据异常时，会导致您的收缩压和舒张压计算结果为0，请您重新测量。</p></div></div></div></div>' +
				'<li class="comFlex js-modal-open6">' +
				'<h2 >舒张压</h2>' +
				'<h3 ><b class="organs0_5">' + sz + '</b></h3>' +
				'</li>' +
				'</ul>' +
				'</div>';
		});
	} else {
		menu2 += '<div class="swiper-slide js-modal-open6" style="width:100%">' +
			'<div><b class="organs0_6"></b></div>' +
			'<ul class="wordages comBox js-modal-open6">' +
			'<li class="comFlex js-modal-open6">' +
			'<h2 >收缩压</h2>' +
			'<h3><b class="organs0_4">--</b></h3>' +
			'</li>' +
			//				'<div class="am-modal am-modal-no-btn" tabindex="-1" id="your-modal6"><div class="am-modal-dialog"><div class="am-modal-hd"><span class="sun_title ico_note2">血压标准 </span><a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a></div><div class="am-modal-bd"><div class="xybz">	<div><table><tr><td>血压定义</td><td>范围（mmHg）</td></tr><tr><td>低血压</td><td>收缩压&lt;90mmHg<br />舒张压&lt;60mmHg</td></tr><tr><td>正常血压</td><td>收缩压（90~120）mmHg<br />舒张压（60~80）mmHg</td></tr><tr><td>血压升高</td><td>收缩压（120〜129）mmHg<br />舒张压&lt;80mmHg</td></tr><tr><td>1期高血压</td><td>收缩压（130-139）mmHg<br />舒张压（80-89）mmHg</td></tr><tr><td>2期高血压</td><td>收缩压≧140<br />舒张压90mmHg</td></tr></table></div><p class="shoudi">当测量数据异常时，会导致您的收缩压和舒张压计算结果为0，请您重新测量。</p></div></div></div></div>' +
			'<li class="comFlex js-modal-open6">' +
			'<h2 >舒张压</h2>' +
			'<h3 ><b class="organs0_5">--</b></h3>' +
			'</li>' +
			'</ul>' +
			'</div>';
	}
	console.log(organs0_data1);
	//	console.log(organs0_data1);

	$(".hh").html(menu);
	var kk = 0;
	var mySwiper = new Swiper('.xue', { //渲染执行
		pagination: '.pagination',
		// loop:true,
		loop: false,
		grabCursor: true,
		paginationClickable: true,
		onSlideChangeEnd: function(swiper) {
			kk = swiper.activeIndex;
			//alert(swiper.activeIndex);
			// swiper.activeIndex 这个就是索引， 从 0 开始！ 可看一共有多少元素！

			//获取swiper的index重新加载
			if(data_arr0) { //获取不同的呼吸率/静息心率/心脏功能
				$(".olState li").html(data_arr0[kk].visceraCode); //运动状态提示
				if(data_arr0[kk].heartRate) {
					$(".organs0_1").html(data_arr0[kk].heartRate);
				} //呼吸率
				if(data_arr0[kk].restingRate) {
					$(".organs0_2").html(data_arr0[kk].restingRate);
				} //静息心率
				if(data_arr0[kk].cardiacFunc) {
					$(".organs0_3").html(data_arr0[kk].cardiacFunc);
				} //心脏功能
			}

		},
	});
	$('.arrow-left').on('click', function(e) {
		e.preventDefault();
		mySwiper.swipePrev();
	});
	$('.arrow-right').on('click', function(e) {
		e.preventDefault();
		mySwiper.swipeNext();
	});

	//血压翻页

	$(".ha").html(menu2);
	var kk2 = 0;
	var mySwiper2 = new Swiper('.huhu', { //渲染执行
		pagination: '.pagination',
		// loop:true,
		loop: false,
		grabCursor: true,
		paginationClickable: true,
		onSlideChangeEnd: function(swiper) {
			kk2 = swiper.activeIndex;
			//			alert(swiper.activeIndex);
			// swiper.activeIndex 这个就是索引， 从 0 开始！ 可看一共有多少元素！

			//获取swiper的index重新加载
			if(data_arr0) { //获取不同的呼吸率/静息心率/心脏功能
				$(".olState li").html(data_arr0[kk2].visceraCode); //运动状态提示
				//				if(data_arr0[kk2].systolicPressure) {
				//					$(".organs0_4").html(data_arr0[kk2].systolicPressure);
				//				} //收缩压
				//				if(data_arr0[kk2].diastolicPressure) {
				//					$(".organs0_5").html(data_arr0[kk2].diastolicPressure);
				//				} //舒张压
			}

		},
	});
	$('.arrow-left2').on('click', function(e) {
		e.preventDefault();
		mySwiper2.swipePrev();
	});
	$('.arrow-right2').on('click', function(e) {
		e.preventDefault();
		mySwiper2.swipeNext();
	});

	// 脏腑0
	var option4 = {
		grid: {
			y: 10,
			x2: 14,
			y2: 10,
			x: 14
		},
		tooltip: {
			show: false,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
		},
		radar: {
			name: {
				textStyle: {
					fontSize: 14,
					color: '#333',
				}
			},
			splitNumber: 3,
			indicator: [
				/*
				{ text: '心脏', max: 650},
				{ text: '肝脏', max: 1600},
				{ text: '肾脏', max: 3000},
				{ text: '脾脏', max: 3800},
				{ text: '肺脏', max: 5200},
				*/
				{
					text: '心脏',
					max: 200
				},
				{
					text: '肝脏',
					max: 200
				},
				{
					text: '肾脏',
					max: 200
				},
				{
					text: '脾脏',
					max: 200
				},
				{
					text: '肺脏',
					max: 200
				},
			]
		},
		series: [{
			type: 'radar',
			data: organs0_data1
		}]
	};

	var option5 = {
		grid: {
			y: 50,
			x2: 14,
			y2: 30,
			x: 14,
		},
		// grid:{y:50, x2:14, y2:30, x:50,},
		tooltip: { // 提示框
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 75, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemp[0] + '月' + timeTemp[1] + '日';
				var res = '<div class="tooltip"><p>' + timeShow + '</p>';
				for(var i = 0; i < params.length; i++) {
					if(params[i].seriesName == "心脏") {
						if(params[i].data) {
							res += '<p class="p_ico1">心脏：' + params[i].data + '</p>'
						} else {
							res += '<p class="p_ico1">心脏：---</p>'
						}
					} else if(params[i].seriesName == "肝脏") {
						if(params[i].data) {
							res += '<p class="p_ico2">肝脏：' + params[i].data + '</p>'
						} else {
							res += '<p class="p_ico2">肝脏：---</p>'
						}
					} else if(params[i].seriesName == "肾脏") {
						if(params[i].data) {
							res += '<p class="p_ico3">肾脏：' + params[i].data + '</p>'
						} else {
							res += '<p class="p_ico3">肾脏：---</p>'
						}
					} else if(params[i].seriesName == "脾脏") {
						if(params[i].data) {
							res += '<p class="p_ico4">脾脏：' + params[i].data + '</p>'
						} else {
							res += '<p class="p_ico4">脾脏：---</p>'
						}
					} else if(params[i].seriesName == "肺脏") {
						if(params[i].data) {
							res += '<p class="p_ico5">肺脏：' + params[i].data + '</p>'
						} else {
							res += '<p class="p_ico5">肺脏：---</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		xAxis: {
			type: 'category',
			boundaryGap: true,
			data: uesTemp,
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			// scale: true,
			max: 200,
			min: 0,
			interval: 70, //强制刻度间隔
			// splitNumber: 5,//自动刻度间隔
			type: 'value',
			axisLabel: {
				show: false,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: true,
				areaStyle: {
					color: ['#fff', '#f6f6f6', '#fff']
				}
			}
		},
		color: ['#d73835', '#66bb6a', '#b28850', '#fad53e', '#78909c'],
		legend: { //图例
			x: 'center',
			itemWidth: 15,
			itemHeight: 6,
			itemGap: 20,
			data: [{
					name: '心脏',
					icon: 'rect',
				}, {
					name: '肝脏',
					icon: 'rect'
				},
				{
					name: '肾脏',
					icon: 'rect'
				}, {
					name: '脾脏',
					icon: 'rect'
				},
				{
					name: '肺脏',
					icon: 'rect'
				}
			],
		},
		series: [{
			name: '心脏',
			type: 'line',
			smooth: true,
			data: organs1_data1,
			// symbol:'null', symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#d73835'
					}
				}
			},
		}, {
			name: '肝脏',
			type: 'line',
			smooth: true,
			data: organs1_data2,
			// symbol:'null', symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#66bb6a'
					}
				}
			},
		}, {
			name: '肾脏',
			type: 'line',
			smooth: true,
			data: organs1_data3,
			// symbol:'null', symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#b28850'
					}
				}
			},
		}, {
			name: '脾脏',
			type: 'line',
			smooth: true,
			data: organs1_data4,
			// symbol:'null', symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#fad53e'
					}
				}
			},
		}, {
			name: '肺脏',
			type: 'line',
			smooth: true,
			data: organs1_data5,
			// symbol:'null', symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#78909c'
					}
				}
			},
		}, ],
	};
	//血压
	var orgin_xy = {
		legend: {
			data: ['低压', '高压', '差值'],
			show: false
		},
		grid: {
			y: 10,
			x2: 30,
			y2: 20,
			x: 30,
		},
		xAxis: {
			type: 'category',
			data: uesTemp,
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			type: 'value',
			min: 40, // y轴可设置最小值，当然你也可以设置最大值max
			max: 160,
			interval: 20, // 刻度线的距离
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		tooltip: { // 提示框
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',

				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 100, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemps = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemps[0] + '月' + timeTemps[1] + '日';
				var res = '<div class="tooltip"><p>' + timeShow + '</p>';
				var shou = ''; //收缩压
				var shu = ''; //舒张压
				for(var i = 0; i < params.length; i++) {
					var stepTemp = Math.floor(params[0].data) + Math.floor(params[1].data);
					if(i == 0) {
						if(params[i].data) {
							shu += '<p>舒张压 ' + params[i].data + '</p>'
						} else {
							shu += '<p>舒张压 ---</p>'
						}
					} else if(i == 2) {
						if(params[i].data) {
							shou += '<p>收缩压 ' + params[i].data + '</p>'
						} else {
							shou += '<p>收缩压 ---</p>'
						}
					}
				}
				res += shou + shu;
				res += '</div>';
				return res;
			},
		},
		series: [{
				name: '低压',
				type: 'bar',
				stack: '血压',
				barWidth: 6,
				data: organs1_data7,
				itemStyle: {
					normal: {
						color: 'transparent' // 底部设置为透明，就可以不显示了
					}
				},
				markLine: { // 用markLine设置血压正常范围的表现
					symbol: ['none', 'none'],
					lineStyle: {
						normal: {
							color: 'green'
						}
					},
					data: [{
						yAxis: 80
					}, {
						yAxis: 130
					}],
				}
			}, {
				name: '差值',
				type: 'bar',
				stack: '血压',
				barWidth: 8,
				label: {
					normal: {
						show: false,
						position: 'top'
					}
				},
				itemStyle: {
					normal: {
						color: '#00A8B5' // 底部设置为透明，就可以不显示了
					}
				},
				data: organs1_data8 // 显示的这一部分柱状图，应该为血压最大值-最小值的差值
			},
			{
				name: '高压',
				type: 'bar',
				barWidth: 6,
				barGap: '-100%',
				itemStyle: {
					normal: {
						color: 'transparent' // 底部设置为透明，就可以不显示了
					}
				},
				data: organs1_data6 // 显示的这一部分柱状图，应该为血压最大值-最小值的差值
			}
		]
	};
	echarts.init(document.getElementById("organs2")).setOption(orgin_xy, true);
	echarts.init(document.getElementById("organs0")).setOption(option4, true);

	echarts.init(document.getElementById("organs1")).setOption(option5, true);

	var dayShow = 0;
	$('.cardiac_btn b').on("click", function() {
		//		$(this).toggleClass('on').siblings('b').toggleClass('on');
		if(dayShow == 1) {
			$(".nowShow").addClass('on');
			$(".dayShow").removeClass('on');
			dayShow = 0;
			$(".cardiac_btn h1").addClass('dn');
			$('.cardiac_now').css('z-index', '-10');

			$(".olState_zf li").html(data.visceraCode); //运动状态提示
			//重新获取呼吸率/静息心率/心脏功能
			if(data.heartRate) {
				$(".organs0_1").html(data.heartRate);
			} //呼吸率
			if(data.restingRate) {
				$(".organs0_2").html(data.restingRate);
			} //静息心率
			if(data.cardiacFunc) {
				$(".organs0_3").html(data.cardiacFunc);
			} //心脏功能
		} else if(dayShow == 0) {
			$(".dayShow").addClass('on');
			$(".nowShow").removeClass('on');
			dayShow = 1;
			$(".cardiac_btn h1").removeClass('dn');
			$('.cardiac_now').css('z-index', '10');
			//获取swiper的index重新加载
			if(data_arr0) { //获取不同的呼吸率/静息心率/心脏功能

				$(".olState_zf li").html(data_arr0[kk].visceraCode); //运动状态提示
				if(data_arr0[kk].heartRate) {
					$(".organs0_1").html(data_arr0[kk].heartRate);
				} //呼吸率
				if(data_arr0[kk].restingRate) {
					$(".organs0_2").html(data_arr0[kk].restingRate);
				} //静息心率
				if(data_arr0[kk].cardiacFunc) {
					$(".organs0_3").html(data_arr0[kk].cardiacFunc);
				} //心脏功能
			}

		}
	});

	//各雷达图-公共
	var option_com = {
		grid: {
			y: 10,
			x2: 14,
			y2: 10,
			x: 14
		},
		tooltip: {
			show: false
		},
		radar: {
			name: {
				textStyle: {
					fontSize: 14,
					color: '#333',
				}
			},
			splitNumber: 3,
			indicator: [{
					text: '心脏',
					max: 200
				},
				{
					text: '肝脏',
					max: 200
				},
				{
					text: '肾脏',
					max: 200
				},
				{
					text: '脾脏',
					max: 200
				},
				{
					text: '肺脏',
					max: 200
				},
			]
		},
		series: [{
			name: '',
			type: 'radar',
			data: []
		}]
	};
	for(var i = 0; i < organs0_data1.length; i++) {
		option_com.series[0].data[0] = organs0_data1[i];
		echarts.init(document.getElementById('organs_sub' + i)).setOption(option_com, true)
	}
}

$(function() {
	var $modal1 = $('#your-modal');
	var $modal3 = $('#your-modal3');
	var $modal4 = $('#your-modal4');
	var $modal5 = $('#your-modal5');

	$modal1.siblings('.js-modal-open1').on('click', function(e) {
		var $target = $(e.target);
		if(($target).hasClass('js-modal-open1')) {
			$modal1.modal();
		}
	});

	$modal3.siblings('.js-modal-open3').on('click', function(e) {
		var $target = $(e.target);
		if(($target).hasClass('js-modal-open3')) {
			$modal3.modal();
		}
	});

	$modal4.siblings('.js-modal-open4').on('click', function(e) {
		var $target = $(e.target);
		if(($target).hasClass('js-modal-open4')) {
			$modal4.modal();
		}
	});

	$modal5.siblings('.js-modal-open5').on('click', function(e) {
		var $target = $(e.target);
		if(($target).hasClass('js-modal-open5')) {
			$modal5.modal();
		}
	});
});